//scgen
package action

import (
	"study/app3/source/chatol/entity"
	"study/app3/source/chatol/log"
	"study/app3/source/chatol/service"

	"github.com/zsxm/scgo/chttp"
)

func init() {
	chttp.Action("/chatol/index", index).Get()
	chttp.Action("/chatol/chatol", chatol).Get()
	chttp.Action("/chatol/upload", upload).Post()
}

//gen
func index(c chttp.Context) {
	e := entity.NewMessage()
	c.BindData(e)
	log.Info(e.JSON())
	c.JSON(e.JSON(), true)
}

func chatol(c chttp.Context) {
	e := entity.NewMessageBean()
	service.MessageService.Select(e)
	log.Info("chatol")
	log.Info(c.Request.Header.Get("Content-Type"))
	c.HTML("/chatol/chatol", e.Entitys().JSON())
}

func upload(c chttp.Context) {
	log.Info("upload")
	mfile := c.MultiFile
	mfile.DirName = "chatol"
	mfile.Upload("")
	log.Info(mfile)
	c.HTML("/chatol/chatol", nil)
}
